<div id="content_header">
  <h3>Discount Types</h3>
</div>

{{ categories }}

<form class="form" ng-submit="search()">
  <div class="row">
    <div class="col-md-10 col-lg-10">
      <div class="row">
        <div class="col-md-3">
          <div class="form-group">
            <label for="">Keyword</label>
            <div class="input-group">
              <input class="form-control" type="text" name="keyword" placeholder="Type Name to search" ng-model="searchText.CountryName">
            </div>
          </div>
        </div>
        <div class="col-md-3">
          <div class="form-group">
            <label for="">Search Category</label>
            <select name="" id="" class="form-control" ng-options="search.Value as search.Label for search in searchBy" ng-model="params.search_by">
              <option value="" ng-hide="params.search_by">-- Select Search Category --</option>
            </select>
          </div>
        </div>
        <div class="col-md-3">
          <div class="form-group">
            <label for="">Product Category</label>
            <select name="" id="" class="form-control" ng-options="category.Id as category.Name for category in categories" ng-model="params.category">
              <option value="" ng-hide="params.category">-- Select Product Category --</option>
            </select>
          </div>
        </div>
        <div class="col-md-3">
          <div class="form-group">
            <label for="">Inventory</label>
            <select name="" id="" class="form-control" ng-options="inventory.Id as inventory.Name for inventory in inventories" ng-model="params.inventory">
              <option value="" ng-hide="params.inventory">-- Select Inventory --</option>
            </select>
          </div>
        </div>
      </div>

    </div>
    <div class="col-md-2 col-lg-2">
      <button type="submit" class="btn btn-default">Search</button>
    </div>
  </div>
</form>

<div class="row">
  <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
    <a ui-sref="^.new.in" class="btn btn-primary">Stock In</a>
    <a ui-sref="^.new.out" class="btn btn-primary">Stock Out</a>
    <a ui-sref="^.new.transfer" class="btn btn-primary">Transfer Stock</a>
  </div>
</div>

<br>

<div class="row">
  <div class="col-md-12">
    <label>RESULTS</label>
    <div class="search-message">
      Found <span class="primary-color"><b>{{ items.length | filter:searchText }}</b></span> records
    </div>
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <table class="table table-striped table-bordered" ng-show="items.length > 0">
      <thead>
        <tr>
          <th>Name</th>
          <th>Code</th>
          <th>Maximum Published</th>
          <th>Default Amount</th>
          <th>Default Percentage</th>
          <th>Discount Source Type</th>
          <th>Default Validity</th>
          <th>Action</th>
        </tr>
      </thead>
      <tbody>
        <tr dir-paginate="item in items | orderBy: 'Name' | itemsPerPage: pagesize" total-items="totalItems">
          <!-- <tr ng-repeat="item in items | filter:searchText | orderBy: 'Name'"> -->
          <td>{{ item.Name }}</td>
          <td>{{ item.Prefix }}{{ item.Code }}</td>
          <td>{{ item.MaximumPublished }}</td>
          <td>{{ item.DefaultAmount | currency:'Rp. ' }}</td>
          <td>{{ item.DefaultPercentage }}%</td>
          <td>{{ DiscountSourceTypes[item.DiscountSourceType].Label }}</td>
          <td>{{ item.DefaultValidFrom | date:'mediumDate' }} - {{ item.DefaultValidUntil | date:'mediumDate' }}</td>
          <td>
            <a class="" href ng-really-message="Are you sure?" ng-really-click="delete('discount_types', item.Id, {collection: items, index: $index})"><i class="simple-icon-trash"></i></a>
            <a class="" ui-sref="^.show({id: item.Id})"><i class="simple-icon-magnifier"></i></a>
          </td>
        </tr>
      </tbody>
    </table>
    <dir-pagination-controls on-page-change="pageChanged(newPageNumber)" template-url="views/templates/dirPagination.tpl.html"></dir-pagination-controls>
  </div>
</div>